package com.hisan.freeride.home.activity;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.WindowManager;


import com.hisan.freeride.R;
import com.hisan.freeride.common.base.BaseActivity;
import com.hisan.freeride.common.utils.CollectionUtils;
import com.hisan.freeride.databinding.CodeBinding;

import cn.bertsir.zbar.QRUtils;

/**
 * 二维码页面
 * Created by admin on 2017/5/20.
 */

public class CodeActivity extends BaseActivity<CodeBinding> {

    private Intent intent;
    String code="";
    @Override
    protected int getLayoutId() {
        return R.layout.code;
    }

    @Override
    protected void initView() {
        Bundle bundle=  getIntent().getExtras();
        if (!CollectionUtils.isNullOrEmpty(bundle)){
             code= bundle.getString("code");
            mBinding.codeText.setText(code);
            String site= bundle.getString("site");
            if (!CollectionUtils.isNullOrEmpty(site)){
                mBinding.site.setText("收货地址："+site);
            }
        }
    }

    @Override
    protected void initEvent() {
        mBinding.topBack.setOnClickListener(v -> {
            if (!CollectionUtils.isNullOrEmpty(intent))intent=new Intent();
            setResult(99,intent);
            finishActivity(true);
        });
    }

    @Override
    protected void loadData(boolean isRefresh) {
        mBinding.qrcodeImg.setImageBitmap( QRUtils.getInstance().createQRCode(code));
    }


}
